package com.zzg.springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zzg.springboot.configbean.ConfigBean;
import com.zzg.springboot.configbean.CustomizeBean;

@Controller
@RequestMapping("/api/configuration")
public class ConfigurationController {
	 //通过注解@Value(value=”${com.zzg.springboot.configuration}”)绑定对应application.properties 自定义属性。
	 @Value("${com.zzg.springboot.configuration}")
	 private String name;
	 //自动注入自定义配置对象ConfigBean
	 @Autowired
	 private ConfigBean object;
	//自动注入自定义配置对象CustomizeBean
	 @Autowired
	 private CustomizeBean customize;
	 
	 /**
	  * 
	  * @Title: getApplication   
	  * @Description: 获取application.properties自定义属性(单一)   
	  * @param: @return      
	  * @return: String      
	  * @throws
	  */
	 @RequestMapping(value="/getApplication", method={RequestMethod.GET})
	 @ResponseBody
	 public String getApplication() {
		 return name;
	 }
	 
	 /**
	  * 
	  * @Title: getApplicationBean   
	  * @Description: 获取application.properties自定义属性(对象)  
	  * @param: @return      
	  * @return: String      
	  * @throws
	  */
	 @RequestMapping(value="/getApplicationBean", method={RequestMethod.GET})
	 @ResponseBody
	 public String getApplicationBean() {
		 return object.getName() + "/" + object.getAddress();
	 }
	 
	 /**
	  * 
	  * @Title: getCustomizeBean   
	  * @Description: 获取第三方配置文件customize.properties自定义属性(对象)  
	  * @param: @return      
	  * @return: String      
	  * @throws
	  */
	 @RequestMapping(value="/getCustomizeBean", method={RequestMethod.GET})
	 @ResponseBody
	 public String getCustomizeBean() {
		 return customize.getName() + "/" + customize.getAddress();
	 }
	 

}
